package com.wxy.care.config;

import com.wxy.care.KnnUtils.Instance;
import com.wxy.care.KnnUtils.KNN;
import com.wxy.care.KnnUtils.TrainingSet;
import com.wxy.care.common.MeanOfNo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class KnnConfig {
    @Bean
    public KNN getKnn(){
        KNN knn = new KNN(3);
        TrainingSet trainingSet = new TrainingSet();
//        {卧室=1.0, 厕所=1.0, 厨房=1.0, 外出=1.0, 客厅=1.0, 时间=1.68543371241E12}
//        trainingSet.addInstance(new Instance(new double[] {0,1,0,0,0,6}, "厕所"));
//        trainingSet.addInstance(new Instance(new double[] {0,1,0,0,0,5}, "厕所"));
//        trainingSet.addInstance(new Instance(new double[] {0,0,1,0,0,17}, "厨房"));
//        trainingSet.addInstance(new Instance(new double[] {0,0,1,0,0,18}, "厨房"));
//        trainingSet.addInstance(new Instance(new double[] {0,0,0,0,1,20}, "客厅"));
//        trainingSet.addInstance(new Instance(new double[] {0,0,0,0,1,21}, "客厅"));
//        trainingSet.addInstance(new Instance(new double[] {1,0,0,0,0,21}, "卧室"));
//        trainingSet.addInstance(new Instance(new double[] {1,0,0,0,0,22}, "卧室"));
//        trainingSet.addInstance(new Instance(new double[] {0,0,0,1,0,19}, "外出"));
//        trainingSet.addInstance(new Instance(new double[] {0,0,0,1,0,18}, "外出"));
        //坏习惯
        double[] hb1 = new double[40];
        hb1[MeanOfNo.weishengjian] = 10;
        trainingSet.addInstance(new Instance(hb1, "bad"));
        double[] hb2  = new double[40];
        hb2[MeanOfNo.weishengjianmenkou] = 9;
        trainingSet.addInstance(new Instance(hb2, "bad"));
        double[] hb3 = new double[40];
        hb3[MeanOfNo.weishengjian] = 12;
        trainingSet.addInstance(new Instance(hb3, "bad"));
        double[] hb4  = new double[40];
        hb4[MeanOfNo.weishengjianmenkou] = 11;
        trainingSet.addInstance(new Instance(hb4, "bad"));
        double[] hb5 = new double[40];
        hb5[MeanOfNo.weishengjian] = 11;
        trainingSet.addInstance(new Instance(hb5, "bad"));
        double[] hb6  = new double[40];
        hb6[MeanOfNo.weishengjianmenkou] = 13;
        trainingSet.addInstance(new Instance(hb6, "bad"));

        //好习惯
        double[] hg1  = new double[40];
        hg1[MeanOfNo.keting] = 3;
        trainingSet.addInstance(new Instance(hg1, "good"));
        double[] hg2  = new double[40];
        hg2[MeanOfNo.keting] = 3;
        trainingSet.addInstance(new Instance(hg2, "good"));
        double[] hg3  = new double[40];
        hg1[MeanOfNo.canting] = 3;
        trainingSet.addInstance(new Instance(hg3, "good"));
        double[] hg4  = new double[40];
        hg4[MeanOfNo.canting] = 3;
        trainingSet.addInstance(new Instance(hg4, "good"));
        double[] hg5  = new double[40];
        hg5[MeanOfNo.xiyifan] = 3;
        trainingSet.addInstance(new Instance(hg5, "good"));
        double[] hg6  = new double[40];
        hg6[MeanOfNo.xiyifan] = 3;
        trainingSet.addInstance(new Instance(hg6, "good"));
        double[] hg7  = new double[40];
        hg7[MeanOfNo.langdao] = 3;
        trainingSet.addInstance(new Instance(hg7, "good"));
        double[] hg8  = new double[40];
        hg8[MeanOfNo.langdao] = 3;
        trainingSet.addInstance(new Instance(hg8, "good"));

        for (Instance instance : trainingSet.getInstances()) {
            knn.addInstance(instance);
        }
        return knn;
    }
}
